import request from '@/utils/request'
// 查询【请填写功能名称】列表
export function listbill(query) {
  return request({
    url: '/lgorder/outorder/getlist',
    method: 'get',
    params: query
  })
}
// 查询id查询订单
export function getBillById(id) {
  return request({
    url: '/lgorder/outorder/getInfo/' + id,
    method: 'get'
  })
}
// 修改订单
export function updateBill(data) {
  return request({
    url: '/lgorder/outorder/edit',
    method: 'post',
    data: data
  })
}

//新增订单
export function addBill(data) {
  return request({
    url: '/lgorder/outorder/add',
    method: 'post',
    data: data
  })
}
// 删除订单
export function delBill(billId) {
  return request({
    url: '/lgorder/order/remove/' + billId,
    method: 'get'
  })
}
//查询司机列表
export function listdriver(query) {
  return request({
    url: '/lgorder/order/getlistdriver',
    method: 'get',
    params: query
  })
}
//查询车辆列表
export function listcar(query) {
  return request({
    url: '/lgorder/order/getlistcar',
    method: 'get',
    params: query
  })
}

// 指派司机
export function assignDriverToOrder(orderNumber, driverId,buyerName, buyerPhone,goodsNameOptions) {
  return request({
    url: '/lgorder/outorder/driver', // 后端接收指派车辆的接口路径
    method: 'post',
    data: {
      orderNumber: orderNumber, // 传递订单编号
      driverId: driverId // 传递车辆 ID
      ,buyerName:buyerName,
      buyerPhone:buyerPhone,
      goodsNameOptions:goodsNameOptions
    }
  })
}



// 指派车辆
export function assignCarToOrder(orderNumber, carId,coldId, buyerName, buyerPhone,goodsNameOptions) {
  return request({
    url: '/lgorder/outorder/assignCar', // 后端接收指派车辆的接口路径
    method: 'post',
    data: {
      orderNumber: orderNumber, // 传递订单编号
      carId: carId ,// 传递车辆 ID
      buyerName:buyerName,
      buyerPhone:buyerPhone,
      goodsNameOptions:goodsNameOptions,
      coldId:coldId
    }
  })
}

//调用仓库类型
export function getWarehouseType() {
  return request({
    url: '/lgorder/order/getColdSome',
    method: 'get'
  })
}
//调用仓库类型
export function geUnitType() {
  return request({
    url: '/lgorder/order/getUnitAll',
    method: 'get'
  })
}
//调用货物类型
export function getGoodsType() {
  return request({
    url: '/lgorder/order/getParent',
    method: 'get'
  })
}
export function getSubGoodsByParentId(parentId) {
  return request({
    url: `/lgorder/order/getParentId/`+parentId,
    method: 'get'
  })
}
export function listOrders(query) {
  return request({
    url: '/lgorder/carorder/getlist',
    method: 'get',
    params: query
  })
}
